<{if empty($store['store_id'])}>
<form id="add_link" action='<{link app="verification" ctl="admin_stores" act="addStore"}>' method="POST" class="tableform">
<{else /}>
<form id="add_link" action='<{link app="verification" ctl="admin_stores" act="editStore"}>' method="POST" class="tableform">
<{/if}>
    <div class="division">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" >
        
        	<{if $seller['seller_id'] gt 0}>
        	<tr>
                <th><em class="red">*</em>所属商户：</th>
                <td>
                	<{$seller.seller_name}>
                </td>
            </tr>
        	<{/if}>
            
            <{if empty($store['store_id'])}>
            <tr>
                <th><em class="red">*</em>门店编号：</th>
                <td>
                    <{input type='text' name='store_num' id="store_num" value=$store.store_num vtype='required' required='true' size=30}>(长度为8位)(长度为8位，不允许修改)
                </td>
            </tr>
            <{else /}>
            <tr>
                <th><em class="red">*</em>门店编号：</th>
                <td>
                    <{input type='text' readonly="readonly" name='store_num' id="store_num" value=$store.store_num vtype='required' required='true' size=30}>(长度为8位，不允许修改)
                </td>
            </tr>
            <{/if}>
            <tr>
                <th><em class="red">*</em>门店名称：</th>
                <td>
                	<{input type="text" name="store_name" value=$store.store_name vtype="required" required="true" size=30}>
                </td>
            </tr>
            <tr>
                <th>门店图片：</th>
                <td>
                    <{input type='image' image_url="images" value=$store.images|default:''}>
                </td>
            </tr>
            <tr>
                <th>门店地址：</th>
                <td>
                	<textarea name="address" class="x-input" ><{$store.address|default:''}></textarea>
                </td>
            </tr>
            <tr>
                <th>门店电话：</th>
                <td>
                	<input type="text" name="tel" value="<{$store.tel|default:''}>" class="x-input" />
                </td>
            </tr>
            <tr>
                <th>地区：</th>
                <td>
                    <input type="text" name="province" value="<{$store.province|default:''}>" class="x-input" style="width:80px;">省
                    <input type="text" name="city" value="<{$store.city|default:''}>" class="x-input" style="width:80px;">市
                    <input type="text" name="area" value="<{$store.area|default:''}>" class="x-input" style="width:80px;">区
                </td>
            </tr>
            <tr>
                <th>经度：</th>
                <td><{input  type="text" name='longitude' value=$store.longitude|default:'' }>
                <span style="margin-right:10px;"></span>
                纬度：<{input  type="text" name='latitude' value=$store.latitude|default:'' }></td>
            </tr>
            <tr>
                <th>排序：</th>
                <td>
                    <{input type="text" name="sort" id="sort" value=$store.sort|default:1 vtype="required" required="true" size=5}>
                </td>
            </tr>
        </table>
    </div>
    <input type="hidden" value="<{$seller.seller_id}>" name="seller_id">
    <{if !empty($store['store_id'])}>
    <input type="hidden" value="<{$store.store_id}>" name="store_id">
    <{/if}>
    <div class="table-action">
        <{button type='button' label=$___a='保存'|t:'verification' onclick="sub_form(event);" }>
    </div>
</form>

<script>

function sub_form(event) {
    var $store_num = ($('store_num').get('value')).trim();
    var $sort = parseInt($('sort').get('value'));
    if( $store_num.length != 8 || isNaN($store_num)){
        alert('错误：门店号必须是8位数字');
        return false;
    }

    if(isNaN($sort) || $sort > 99999){
        alert('错误：排序必须为不超过5位数的数字');
        return false;
    }
    $('add_link').fireEvent('submit',new Event(event));
}

$('add_link').store('target',{
    onComplete:function($data){
        $data = eval("("+$data+')');
        if($data.success){
            $('add_link').getParent('.dialog').retrieve('instance').close();
        }
    }
});
</script>